/**
*
* 2007-11-3 上午09:00:53
* @author xuhuan
*/

package edu.ccut.saturn.studio.logic.model.saturn;

import edu.ccut.saturn.studio.logic.model.Connection;
import edu.ccut.saturn.studio.logic.model.Shape;

public class SaturnFalseConnection extends Connection {

	private static final String SATURN_FALSE_CONNECTION_NULL = "";

	public SaturnFalseConnection(Shape source, Shape target, int style) {
		super(source, target, style);
	}

	private static final long serialVersionUID = -3193599943610492055L;

	@Override
	public void reconnect() {
		if (!super.isConnected()) {
			Shape source = super.getSource();
			
			if (source instanceof SaturnDecisionNode) {
				SaturnDecisionNode decisionNode = (SaturnDecisionNode)source;
				
				decisionNode.addConnection(this);
				super.getTarget().addConnection(this);
				super.setConnected(true);
			
				decisionNode.setFalseId(super.getTarget().getId());
			}
		}
	}

	@Override
	public void disconnect() {
		if (super.isConnected()) {
			Shape source = super.getSource();
			
			if (source instanceof SaturnDecisionNode) {
				SaturnDecisionNode decisionNode = (SaturnDecisionNode)source;
				
				decisionNode.removeConnection(this);
				super.getTarget().removeConnection(this);
				super.setConnected(false);
			
				decisionNode.setFalseId(SATURN_FALSE_CONNECTION_NULL);
			}
		}
	}
	
	//TODO: 颜色
}
